package com.usth.action;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.usth.model.BuyTVO;
import com.usth.model.FlightVO;
import com.usth.model.SoldTicket;
import com.usth.model.User;
import com.usth.service.ITicketsService;

public class TicketsAction {
private ITicketsService ticketservice;
private BuyTVO bvo;
private FlightVO fvo;
private Double price;
private String bcard;
private List<SoldTicket> tlist;
private int sid;
//private List<SoldTicket> soldlist;
public int getSid() {
	return sid;
}
public void setSid(int sid) {
	this.sid = sid;
}
public List<SoldTicket> getTlist() {
	return tlist;
}
public void setTlist(List<SoldTicket> tlist) {
	this.tlist = tlist;
}
public String getBcard() {
	return bcard;
}
public void setBcard(String bcard) {
	this.bcard = bcard;
}
public Double getPrice() {
	return price;
}
public void setPrice(Double price) {
	this.price = price;
}
public FlightVO getFvo() {
	return fvo;
}
public void setFvo(FlightVO fvo) {
	this.fvo = fvo;
}
public ITicketsService getTicketservice() {
	return ticketservice;
}
public void setTicketservice(ITicketsService ticketservice) {
	this.ticketservice = ticketservice;
}
public BuyTVO getBvo() {
	return bvo;
}
public void setBvo(BuyTVO bvo) {
	this.bvo = bvo;
}
public String buytickets(){
	this.bvo.setFvo(fvo);
	this.ticketservice.buytickets(bvo);
	return "buyt";
}
public String pay(){
	HttpSession session=ServletActionContext.getRequest().getSession();
	String s=this.ticketservice.pay(price, bcard);
	session.setAttribute("msg", s);
	return "pay";
}
public String precp(){
	this.setTlist(this.ticketservice.percp());
	return "precp";
}
public String cp(){
	this.ticketservice.cp(sid);
	return "cp";
}
public String pretp(){
	this.setTlist(this.ticketservice.pretp());
	return "pretp";
}
public String tp(){
	this.ticketservice.tp(sid);
	return "tp";
}
public String  userallt(){
	HttpSession session=ServletActionContext.getRequest().getSession();
	this.setTlist(this.ticketservice.userallt(((User)session.getAttribute("user")).getUserId()));
	return "userallt";
}
public String returnticket(){
	this.ticketservice.returnticket(sid);
	return "returnticket";
}
public String cancelreturn(){
	this.ticketservice.cancelreturn(sid);
	return "returnticket";
}
public String payt(){
	Double d=this.ticketservice.payt(sid);
	HttpSession session=ServletActionContext.getRequest().getSession();
	session.setAttribute("tprice", d);
	return "buyt";
}
}
